package com.bizdk.generator.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bizdk.generator.common.page.PageResult;
import com.bizdk.generator.common.query.Query;
import com.bizdk.generator.entity.gen.Group;
import com.bizdk.generator.mapper.GroupMapper;
import com.bizdk.generator.service.GroupService;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
 * 项目名变更
 */
@Service
@AllArgsConstructor
public class GroupServiceImpl extends ServiceImpl<GroupMapper, Group> implements GroupService {
    
    @Override
    public PageResult<Group> page(Query query) {
        IPage<Group> page = baseMapper.selectPage(new Page<>(query.getPageNum(), query.getPageSize()), query.getWrapper());
        
        return new PageResult<>(page.getRecords(), page.getTotal());
    }
    
    @Override
    public boolean save(Group entity) {
        entity.setCreateTime(new Date());
        return super.save(entity);
    }
}